# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=kubepug
pkgver=1.7.1
pkgrel=0
pkgdesc="Kubernetes pre-upgrade deprecation checker"
url="https://github.com/rikatz/kubepug"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/rikatz/kubepug/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	local _goldflags="
	-X sigs.k8s.io/release-utils/version.gitVersion=v$pkgver
	-X sigs.k8s.io/release-utils/version.gitCommit=AlpineLinux
	-X sigs.k8s.io/release-utils/version.gitTreeState=clean
	-X sigs.k8s.io/release-utils/version.buildDate=$(date -u '+%Y-%m-%dT%H:%M:%SZ' ${SOURCE_DATE_EPOCH:+-d @$SOURCE_DATE_EPOCH})
	"
	go build -v -ldflags "$_goldflags" -o bin/$pkgname

	for shell in bash zsh fish; do
		./bin/kubepug completion $shell > kubepug.$shell
	done
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/$pkgname -t "$pkgdir"/usr/bin

	install -Dm644 kubepug.bash \
		"$pkgdir"/usr/share/bash-completion/completions/kubepug
	install -Dm644 kubepug.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_kubepug
	install -Dm644 kubepug.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/kubepug.fish
}

sha512sums="
a04411b6e51a9ffa49c80c23391546478dc912bafffff85dcdaf931167f9cc4844120360871d177120c7f50b04e01a40fbf0694759dc5973ec5ee18d8d285d6d  kubepug-1.7.1.tar.gz
"
